const Core = require('@alicloud/pop-core');

// 配置阿里云短信服务
const client = new Core({
    accessKeyId: '',
    accessKeySecret: '',
    endpoint: 'https://dysmsapi.aliyuncs.com',
    apiVersion: '2017-05-25'
});

// 发送验证码的函数
const sendVerificationCode = (phoneNumber, code) => {
    const params = {
        "RegionId": "cn-hangzhou",
        "PhoneNumbers": phoneNumber,
        "SignName": "yzm实现",
        "TemplateCode": "SMS_479960123",
        "TemplateParam": `{"code": "${code}"}`
    };

    const requestOption = {
        method: 'POST'
    };

    return client.request('SendSms', params, requestOption);
};

module.exports = {
    sendVerificationCode
};